Type.registerNamespace("Telerik.Web.UI");
Type.registerNamespace("Telerik.Web.UI.ProgressManager");
function getRadProgressManager(){return Telerik.Web.UI.ProgressManager.Manager;
}function RadUploadSafariPoller(b,d,a,c){this._callbackUrl=b;
this._refreshPeriod=d;
this._waitingForResponse=false;
this._timeFormat=a;
}function RadUploadSafariProgressArea(a){this._id=a;
if(typeof(window.progressAreas)=="undefined"){window.progressAreas=[];
}window.progressAreas[window.progressAreas.length]=this;
}Telerik.Web.UI.RadProgressManager=function(a){Telerik.Web.UI.RadProgressManager.initializeBase(this,[a]);
this._uniqueRequestIdentifier="RadUrid";
this._formId="";
this._form=null;
this._pageGUID="";
this._suppressMissingHttpModuleError=false;
this._refreshPeriod=500;
this._shouldRegisterForSubmit=true;
this._ajaxCallUrl="";
$telerik.RadUpload_isIFrameProgress=$telerik.isSafari||$telerik.isOpera;
this._disposed=false;
this._timeFormat="%HOURS%:%MINUTES%:%SECONDS%s";
};
Telerik.Web.UI.RadProgressManager.prototype={initialize:function(){Telerik.Web.UI.RadProgressManager.callBaseMethod(this,"initialize");
this._registerAsPageManager();
this._initializeForm();
this._callbackUrl=this._createCallbackUrl(this._ajaxCallUrl);
this._waitingForResponse=false;
if(typeof(Telerik.Web.UI.ProgressAreas)=="undefined"){Telerik.Web.UI.ProgressAreas=[];
}if($telerik.RadUpload_isIFrameProgress){this._safariPollerDelegate=Function.createDelegate(this,this._createSafariPoller);
Sys.Application.add_load(this._safariPollerDelegate);
}},dispose:function(){this._disposed=true;
if(this._form&&this._shouldRegisterForSubmit==true){$removeHandler(this._form,"submit",this._clientSubmitDelegate);
this._clientSubmitDelegate=null;
}if($telerik.RadUpload_isIFrameProgress&&this._safariPollerDelegate){Sys.Application.remove_load(this._safariPollerDelegate);
this._safariPollerDelegate=null;
}Telerik.Web.UI.RadProgressManager.callBaseMethod(this,"dispose");
},_getSafariPollerDefinition:function(){RadUploadSafariPoller.prototype={_createReadyStateChangeDelegate:this._createReadyStateChangeDelegate,_sendXmlHttpRequest:this._sendXmlHttpRequest,_makeCallback:this._makeCallback,_getTimeStampedCallbackUrl:this._getTimeStampedCallbackUrl,_handleCallback:this._handleCallback,_errorOccured:this._errorOccured,_showNotFoundMessage:this._showNotFoundMessage,_showGenericErrorMessage:this._showGenericErrorMessage,_showInvalidContentMessage:this._showInvalidContentMessage,get_refreshPeriod:this.get_refreshPeriod,_modifyProgressData:this._modifyProgressData,getFormattedTime:this.getFormattedTime,_normalizeTime:this._normalizeTime,_toSeconds:this._toSeconds,_updateProgressAreas:this._updateProgressAreas,_formatTimePart:this._formatTimePart};
return RadUploadSafariPoller;
},_getSafariProgressAreaDefinition:function(){RadUploadSafariProgressArea.prototype={get_id:function(){return this._id;
},show:Telerik.Web.UI.RadProgressArea.prototype.show,update:Telerik.Web.UI.RadProgressArea.prototype.update,updateHorizontalProgressBar:Telerik.Web.UI.RadProgressArea.prototype.updateHorizontalProgressBar,updateTextIndicator:Telerik.Web.UI.RadProgressArea.prototype.updateTextIndicator};
return RadUploadSafariProgressArea;
},_addClassAsString:function(a,d,f){f[f.length]=a.toString();
f[f.length]=";";
f[f.length]=d;
f[f.length]=".prototype = {";
var b=true;
for(var c in a.prototype){var e=a.prototype[c];
if(typeof(e)!="function"){continue;
}if(!b){f[f.length]=",";
}b=false;
f[f.length]=c;
f[f.length]=":";
f[f.length]=e.toString();
}f[f.length]="};";
},_createSafariPoller:function(){this._createSafariIFrame();
},_addSafariProgressAreas:function(a){for(var b=0;
b<Telerik.Web.UI.ProgressAreas.length;
b++){Telerik.Web.UI.ProgressAreas[b]._addSafariDefinition(a);
}},_setupSafariProgressAreas:function(){for(var a=0;
a<Telerik.Web.UI.ProgressAreas.length;
a++){Telerik.Web.UI.ProgressAreas[a]._setupSafariProgressAreaControls();
}},_createSafariIFrame:function(){this._safariPoller=document.createElement("iframe");
this._safariPoller.id=this._safariPoller.name=this.get_id()+"_safariPoller";
this._safariPoller.src="javascript:''";
this._safariPoller.style.display="none";
document.forms[0].appendChild(this._safariPoller);
var a=this._safariPoller.contentWindow.document;
a.open();
var b=[];
b[b.length]="<script type='text/javascript'>";
this._addClassAsString(this._getSafariPollerDefinition(),"RadUploadSafariPoller",b);
b[b.length]="var pollerInstance = new RadUploadSafariPoller('"+this._callbackUrl+"', "+this.get_refreshPeriod()+", '"+this.get_timeFormat()+"');";
b[b.length]="$telerik = {};";
b[b.length]="$telerik.RadUpload_isIFrameProgress = ";
b[b.length]=$telerik.RadUpload_isIFrameProgress.toString();
b[b.length]=";";
if(Telerik.Web.UI.ProgressAreas.length>0){this._addClassAsString(this._getSafariProgressAreaDefinition(),"RadUploadSafariProgressArea",b);
this._addSafariProgressAreas(b);
}b[b.length]="</script>";
a.write("<html><head>"+b.join("")+"</head><body></body></html>");
a.close();
this._setupSafariProgressAreas();
},_getParentForm:function(){var a=this.get_element();
while(a&&a.tagName&&a.tagName.toLowerCase()!="form"){a=a.parentNode;
}if(a&&(!a.tagName||a.tagName.toLowerCase()!="form")){a=null;
}return a;
},_registerAsPageManager:function(){if(!Telerik.Web.UI.ProgressManager.Manager){Telerik.Web.UI.ProgressManager.Manager=this;
}},_initializeForm:function(){var a=null;
this._form=this._getParentForm();
if(!this._form){alert("RadProgressManager requires to be in a form tag to operate properly!");
return;
}this._updateFormAction(this._form);
if(this._shouldRegisterForSubmit==true){this._registerForSubmit(this._form);
}},_updateFormAction:function(a){if(typeof(a.action)=="undefined"){a.action="";
}if(a.action.match(/\?/)){a.action=this._removeQueryStringParameter(a.action,this._uniqueRequestIdentifier);
if(a.action.substring(a.action.length-1)!="?"){a.action+="&";
}}else{a.action+="?";
}a.action+=this._uniqueRequestIdentifier+"="+this._pageGUID;
a.enctype=a.encoding="multipart/form-data";
a._initialAction=a.action;
},_removeQueryStringParameter:function(c,a){var b=new RegExp("&?"+a+"=[^&]*");
if(c.match(b)){return c.replace(b,"");
}return c;
},_registerForSubmit:function(a){this._registerForLinkButtons(a);
this._registerForRegularButtons(a);
},_registerForLinkButtons:function(d){var a=d.submit;
try{var b=this;
d.submit=function(){if(b._clientSubmitHandler()==false){return;
}d.submit=a;
d.submit();
};
}catch(c){try{var e=__doPostBack;
__doPostBack=function(f,g){var h=true;
if(typeof(Page_ClientValidate)=="function"){h=Page_ClientValidate();
}if(h){if(b._clientSubmitHandler()==false){return;
}e(f,g);
}};
}catch(c){}}},_registerForRegularButtons:function(b){this._clientSubmitDelegate=Function.createDelegate(this,this._clientSubmitHandler);
$addHandler(b,"submit",this._clientSubmitDelegate);
if(Sys&&Sys.WebForms&&Sys.WebForms.PageRequestManager){var a=Sys.WebForms.PageRequestManager.getInstance();
if(a){a.add_beginRequest(this._clientSubmitDelegate);
}}},_clientSubmitHandler:function(b){var a=new Sys.CancelEventArgs();
this.raiseEvent("submitting",a);
if(a.get_cancel()){return $telerik.cancelRawEvent(b);
}if(typeof(Page_IsValid)!="undefined"){if(!Page_IsValid){return;
}}this.startProgressPolling();
},startProgressPolling:function(){this._initSelectedFilesCount();
this.raiseEvent("progressStarted");
if($telerik.RadUpload_isIFrameProgress){this._safariPoller.contentWindow.pollerInstance._startTime=new Date();
this._safariPoller.contentWindow.pollerInstance._makeCallback();
this._safariPoller.contentWindow.pollerInstance._selectedFilesCount=this._selectedFilesCount;
}else{this._startTime=new Date();
this._makeCallback();
}},_initSelectedFilesCount:function(){this._selectedFilesCount=0;
var b=document.getElementsByTagName("input");
for(var a=0;
a<b.length;
a++){var c=b[a];
if(c.type=="file"&&c.value!=""){this._selectedFilesCount++;
}}},_createReadyStateChangeDelegate:function(){if(!$telerik.RadUpload_isIFrameProgress){return Function.createDelegate(this,this._handleCallback);
}var a=this;
return function(){a._handleCallback();
};
},_sendXmlHttpRequest:function(){if(typeof(XMLHttpRequest)!="undefined"){this._xmlHttpRequest=new XMLHttpRequest();
}else{if(typeof(ActiveXObject)!="undefined"){this._xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}else{return;
}}this._xmlHttpRequest.onreadystatechange=this._createReadyStateChangeDelegate();
if($telerik.RadUpload_isIFrameProgress){this._xmlHttpRequest.open("GET",this._getTimeStampedCallbackUrl(),false);
}else{this._xmlHttpRequest.open("GET",this._getTimeStampedCallbackUrl(),true);
}this._xmlHttpRequest.send("");
},_makeCallback:function(){if(!this._waitingForResponse){this._waitingForResponse=true;
this._sendXmlHttpRequest();
}},_handleCallback:function(){if(this._xmlHttpRequest.readyState!=4){return;
}this._waitingForResponse=false;
if(this._errorOccured()){return;
}var c=this._xmlHttpRequest.responseText;
if(c){try{eval(c);
}catch(d){this._showInvalidContentMessage();
return;
}if(rawProgressData){if(!this._suppressMissingHttpModuleError&&rawProgressData.ProgressError){this.handleProgressError(rawProgressData.ProgressError);
return;
}if(rawProgressData.InProgress){this._modifyProgressData(rawProgressData);
if(!this._updateProgressAreas(rawProgressData)){this.hideProgressAreas();
this._resetCancelClicked();
if(window.stop){window.stop();
}else{try{document.execCommand("Stop");
}catch(d){window.location.href=window.location.href;
}}return;
}}}}if(this._disposed||(typeof(rawProgressData)!="undefined"&&rawProgressData.OperationComplete&&rawProgressData.OperationComplete.toLowerCase()=="true")){return;
}if($telerik.RadUpload_isIFrameProgress){var b=this;
var a=function(){b._makeCallback();
};
window.setTimeout(a,this.get_refreshPeriod());
}else{if(Function.createDelegate){var a=Function.createDelegate(this,this._makeCallback);
window.setTimeout(a,this.get_refreshPeriod());
}}},_createCallbackUrl:function(b){var a=b.indexOf("?")<0?"?":"&";
return b+a+this._uniqueRequestIdentifier+"="+this._pageGUID;
},_getTimeStampedCallbackUrl:function(){return this._callbackUrl+"&RadUploadTimeStamp="+new Date().getTime()+"&";
},_modifyProgressData:function(a){var b=new Date()-this._startTime;
if(typeof(a.TimeElapsed)=="undefined"){a.TimeElapsed=this.getFormattedTime(this._toSeconds(b));
}else{if(parseInt(a.TimeElapsed).toString()==a.TimeElapsed){a.TimeElapsed=this.getFormattedTime(this._toSeconds(a.TimeElapsed));
}}if(typeof(a.SecondaryTotal)=="undefined"){a.SecondaryTotal=this._selectedFilesCount;
}if(typeof(a.SecondaryPercent)=="undefined"){a.SecondaryPercent=Math.round(100*a.SecondaryValue/(this._selectedFilesCount!=0?this._selectedFilesCount:1));
}if(typeof(a.TimeEstimated)=="undefined"&&typeof(a.PrimaryPercent)=="number"){if(a.PrimaryPercent==0){a.TimeEstimated=this.getFormattedTime(this._toSeconds(359999000));
}else{a.TimeEstimated=this.getFormattedTime(this._toSeconds(b*(100/a.PrimaryPercent-1)));
}}else{if(parseInt(a.TimeEstimated).toString()==a.TimeEstimated){a.TimeEstimated=this.getFormattedTime(this._toSeconds(a.TimeEstimated));
}}},_updateProgressAreas:function(a){if($telerik.RadUpload_isIFrameProgress){if(typeof(window.progressAreas)!="undefined"){for(var b=0;
b<progressAreas.length;
b++){var c=progressAreas[b];
if(c.cancelClicked){return false;
}c.update(a);
}}}else{this.raiseEvent("progressUpdating",{ProgressData:a});
for(var b=0;
b<Telerik.Web.UI.ProgressAreas.length;
b++){var c=Telerik.Web.UI.ProgressAreas[b];
if(c.cancelClicked){return false;
}c.update(a);
}}return true;
},_resetCancelClicked:function(){for(var a=0;
a<Telerik.Web.UI.ProgressAreas.length;
a++){Telerik.Web.UI.ProgressAreas[a].cancelClicked=false;
}this._initializeForm();
},hideProgressAreas:function(){for(var a=0;
a<Telerik.Web.UI.ProgressAreas.length;
a++){Telerik.Web.UI.ProgressAreas[a].hide();
}},_toSeconds:function(a){return Math.round(a/1000);
},_formatBytes:function(c){var a=c/1024;
var b=a/1024;
if(b>0.8){return""+Math.round(b*100)/100+"MB";
}if(a>0.8){return""+Math.round(a*100)/100+"kB";
}return""+c+" bytes";
},getFormattedTime:function(a){var b=this._normalizeTime(a);
return this._timeFormat.replace(/%HOURS%/,b.Hours).replace(/%MINUTES%/,b.Minutes).replace(/%SECONDS%/,b.Seconds);
},_normalizeTime:function(c){var a=this._formatTimePart(c%60);
var e=Math.floor(c/60);
var d=this._formatTimePart(e%60);
var b=this._formatTimePart(Math.floor(e/60));
return{Hours:b,Minutes:d,Seconds:a};
},_formatTimePart:function(a){if(a.toString().length>1){return a.toString();
}return"0"+a.toString();
},_errorOccured:function(){if(!document.all){return false;
}if(this._xmlHttpRequest.status==404){this._showNotFoundMessage();
}else{if(this._xmlHttpRequest.status>0&&this._xmlHttpRequest.status!=200){this._showGenericErrorMessage();
}else{return false;
}}return true;
},_showNotFoundMessage:function(){alert("RadUpload Ajax callback error. Source url was not found: \n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.");
},_showGenericErrorMessage:function(){alert("RadUpload Ajax callback error. Source url returned error: "+this._xmlHttpRequest.status+" \n\r\n\r"+this._xmlHttpRequest.statusText+" \n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.");
},_showInvalidContentMessage:function(){alert("RadUpload Ajax callback error. Source url returned invalid content: \n\r\n\r"+this._xmlHttpRequest.responseText+"\n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.");
},handleProgressError:function(a){alert(a);
},get_formId:function(){return this._formId;
},set_formId:function(a){this._formId=a;
},get_refreshPeriod:function(){return this._refreshPeriod;
},set_refreshPeriod:function(a){if(a&&!isNaN(a)&&a>=500){this._refreshPeriod=a;
}},get_pageGUID:function(){return this._pageGUID;
},set_pageGUID:function(a){this._pageGUID=a;
},get_suppressMissingHttpModuleError:function(){return this._suppressMissingHttpModuleError;
},set_suppressMissingHttpModuleError:function(a){this._suppressMissingHttpModuleError=a;
},get_shouldRegisterForSubmit:function(){return this._shouldRegisterForSubmit;
},set_shouldRegisterForSubmit:function(a){this._shouldRegisterForSubmit=a;
},get_ajaxCallUrl:function(){return this._ajaxCallUrl;
},set_ajaxCallUrl:function(a){this._ajaxCallUrl=a;
},get_timeFormat:function(){return this._timeFormat;
},set_timeFormat:function(a){this._timeFormat=a;
},add_progressStarted:function(a){this.get_events().addHandler("progressStarted",a);
},remove_progressStarted:function(a){this.get_events().removeHandler("progressStarted",a);
},add_progressUpdating:function(a){this.get_events().addHandler("progressUpdating",a);
},remove_progressUpdating:function(a){this.get_events().removeHandler("progressUpdating",a);
},add_submitting:function(a){this.get_events().addHandler("submitting",a);
},remove_submitting:function(a){this.get_events().removeHandler("submitting",a);
}};
Telerik.Web.UI.RadProgressManager.registerClass("Telerik.Web.UI.RadProgressManager",Telerik.Web.UI.RadWebControl);
